﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Tracy.DataModel;
using System.Xml;

namespace Tracy
{
    public class FanSubGroupProvider
    {
        List<FanSubGroup> _fanSubGroups = new List<FanSubGroup>();

        public List<FanSubGroup> FanSubGroups
        {
            get { return _fanSubGroups; }
        }

        Dictionary<string, FanSubGroup> _indexName = new Dictionary<string, FanSubGroup>();
        public FanSubGroup GetItem(string name)
        {
            if(_indexName.ContainsKey(name))
                return _indexName[name];
            return null;
        }

        public FanSubGroupProvider()
        {
            XmlDocument doc = new XmlDocument();
            doc.Load(@"Settings\FanSubGroups.xml");
            foreach(XmlElement fanSubGroupNode in doc.SelectNodes("fan-sub-groups/fan-sub-group")){
                FanSubGroup fanSubGroup = new FanSubGroup(fanSubGroupNode);
                FanSubGroups.Add(fanSubGroup);
                _indexName.Add(fanSubGroup.Name, fanSubGroup);
            }
        }
    }
}
